package com.wtwd.device.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wtwd.device.dao.WeeklySportInfoMapper;
import com.wtwd.device.model.entity.WeeklySportInfo;
import com.wtwd.device.service.WeeklySportInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2022-04-25
 */
@Service
public class WeeklySportInfoServiceImpl implements WeeklySportInfoService {


    @Autowired
    private WeeklySportInfoMapper weeklySportInfoMapper;

    @Override
    public List<WeeklySportInfo> getUserWeekly(Long userId, String startTime, String endTime) {
        return new LambdaQueryChainWrapper<>(weeklySportInfoMapper)
                .eq(WeeklySportInfo::getUserId, userId)
                .eq(StringUtils.isNotBlank(startTime),WeeklySportInfo::getStartTime,startTime)
                .eq(StringUtils.isNotBlank(endTime),WeeklySportInfo::getEndTime,endTime)
                .list();
    }


    @Override
    public Integer bathAddWeekly(List<WeeklySportInfo> weeklySportInfos) {
        return weeklySportInfoMapper.bathAddWeekly(weeklySportInfos);
    }
}
